<template>
	<view>
		  <u--input
		    placeholder="请输入账号"
		    border="bottom"
		    clearable
			v-model="username"
		  ></u--input>
			<u--input
			  placeholder="请输入新密码"
			  border="bottom"
			  clearable
			  v-model="password"
			></u--input>
			<button plain @click="updatePwd">确认</button>
	</view>
</template>

<script>
	export default {
	      data() {
	        return {
	          username: '',
			  password:''
	        }
	      },
		  onLoad(option) {
		  	console.log("重置密码",option.user);
			this.username = option.user;
		  },
	      methods: {
			updatePwd(){
				uni.request({
					url:"http://localhost:10002/user/updatePwd/"+this.username+"/"+this.password,
					method:"GET",
					success:() => {
						uni.showToast({
							duration: 2000,
							title: '密码修改成功',
							icon: 'loading',
							success: () => {
								setTimeout( ()=>{
									this.toReset();
									uni.hideToast();
								},500)
							}
						})
					}
				})
			},
			toReset(){
				uni.navigateTo({
					url:"login"
				})
			}
	      }
		}
</script>

<style>
</style>
